#include "wave_tracer.h"
#include "cpu/cpu.h"

uint32_t sim_time = 0;

#if CONFIG_WAVE_TRACE
VerilatedVcdC* tfp;
void init_wave_tracer(char *filename)
{
    Verilated::traceEverOn(true);
    tfp = new VerilatedVcdC;
    top->trace(tfp, 0);
    tfp->open(filename);
}
void dump_wave()
{
    if(total_cycles < WAVE_TRACE_START_CYCLE) return;
    if(sim_time <= WAVE_MAX_CNT) 
    {
        tfp->dump(sim_time++);
    }
}
void deinit_wave_tracer()
{
    tfp->close();
    delete tfp;
}
#else
void dump_wave() {}
void init_wave_tracer(char *filename) {}
void deinit_wave_tracer() {}
#endif